/**
 * Created by L.jp
 * Description:
 * User: 86189
 * Date: 2022-05-30
 * Time: 21:24
 * @author 86189
 */
public class Main {
    //查找目标数字出现的下标
    public static int findPosition(int[] arr,int target){
        return binarySearch( arr,0,arr.length-1,target );
    }
    public static int binarySearch(int[] arr, int start,int end,int target) {
        if(start>end){
            return -1;
        }
        int mid=(start+end)/2;
        if(arr[mid]==target){
            return mid;
        }
        if(arr[mid]< target){
            return binarySearch( arr,mid+1,end,target );
        }
        return binarySearch( arr,start,mid-1,target );
        
    }
    public static void main (String[] args) {
        int[] arr={1,3,5,7,9,10};
        System.out.println( findPosition( arr , 7 ) );
    }
}
